<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: appHeader"></head>
<body id="history-body" ontouchstart>
<div class="weui-form-preview">
    <div class="weui-form-preview__hd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">转序类型</label>
            <b class="weui-form-preview__item" th:if="${sheet.category == 1}">制作件</b>
            <b class="weui-form-preview__item" th:if="${sheet.category == 2}">装配件</b>
            <b class="weui-form-preview__item" th:if="${sheet.category == 3}">返修票</b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">生产令号</label>
            <b class="weui-form-preview__item" th:text="${sheet.prodNo}">2020F058-01</b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">图号</label>
            <b class="weui-form-preview__item" th:text="${sheet.drawNo}">RLFSSB4T.2.1.2-1</b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">零件名称</label>
            <b class="weui-form-preview__item" th:text="${sheet.drawName}">钢板 44×44×20</b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">零件数量</label>
            <b class="weui-form-preview__item" th:text="${sheet.drawNum}">10</b>
        </div>
    </div>
</div>
<h2 style="margin-top: 16px;text-align: center" th:if="${list.size() == 0}" th:text="${content}"></h2>
<div class="weui-cells">
    <div th:each="r : ${list}" style="border-bottom: 1px solid #e5e5e5;">
        <div class="weui-form-preview__bd" onclick="gotoApplyDetailPage(this)" th:sheetId="${r.sheetId}"
             th:routeId="${r.routeId}" th:processId="${r.processId}">
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">转序类型</label>
                <a class="weui-form-preview__item" th:if="${r.type == 1}">制作件</a>
                <a class="weui-form-preview__item" th:if="${r.type == 2}">装配件</a>
                <a class="weui-form-preview__item" th:if="${r.type == 3}">返修票</a>
            </div>
            <div class="weui-form-preview__item" th:if="${r.type == 3}">
                <label class="weui-form-preview__label">返修票创建时间</label>
                <b class="weui-form-preview__item" th:text="${#dates.format(r.createTime, 'yyyy-MM-dd HH:mm')}"></b>
            </div>
            <div class="weui-form-preview__item" th:if="${r.type != 3}">
                <label class="weui-form-preview__label">工艺路线</label>
                <b class="weui-form-preview__item" th:text="${r.route}+'   '+${r.orderNo}"></b>
            </div>
            <div class="weui-form-preview__item" th:if="${r.process != null}">
                <label class="weui-form-preview__label">工艺工序</label>
                <b class="weui-form-preview__item" th:text="${r.process}+'    '+${r.handNo}"></b>
            </div>
        </div>
    </div>
</div>
<div class="weui-tabbar">
    <a th:href="@{/index}" class="weui-tabbar__item weui-bar__item--on">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/me.png}" alt="">
        </div>
        <p class="weui-tabbar__label">我的信息</p>
    </a>
    <!--生产历史-->
    <a th:if="${#strings.contains(session.user.roles,'【申请质检】')}" th:href="@{/hisApply/null/null}"
       class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_apply.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史申请</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【转序接收】')}" th:href="@{/hisRec/null/null}"
       class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_rec.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史接收</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【转序质检】')}" th:href="@{/hisCheck/null/null}"
       class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_check.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史质检</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【入库质检】')}" onclick="tips()" href="javascript:void(0)"
       class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_check.png}" alt="">
        </div>
        <p class="weui-tabbar__label">入库历史质检</p>
    </a>
</div>
<div th:include="include :: appFooter"></div>
<script th:inline="javascript">
    function gotoApplyDetailPage(obj) {
        let sheetId = $(obj).attr("sheetId");
        let routeId = $(obj).attr("routeId");
        let processId = $(obj).attr("processId");
        if (processId != undefined) {
            location.href = ctx + "gotoApplyDetailPage/" + sheetId + "/" + routeId + "/" + processId;
        } else if(processId == undefined && routeId != undefined) {
            location.href = ctx + "gotoApplyDetailPage/" + sheetId + "/" + routeId + "/0";
        }else if(processId == undefined && routeId == undefined) {
            location.href = ctx + "gotoApplyDetailPage/" + sheetId + "/0/0";
        }
    }

    $(function () {
        $('.weui-count__decrease').click(function (e) {
            let $input = $(e.currentTarget).parent().find('.weui-count__number');
            let number = parseInt($input.val() || "0") - 1
            if (number < 1) {
                number = 1;
            }
            $input.val(number)
        })

        $('.weui-count__increase').click(function (e) {
            let $input = $(e.currentTarget).parent().find('.weui-count__number');
            let max = $input.attr("data");
            let number = parseInt($input.val() || "0") + 1
            if (number > max) {
                number = max;
            }
            $input.val(number)
        })

        // $('.weui-count__number').change(function (e) {
        //     let max = $(this).attr("data");
        //     let number = $(this).val();
        //     if (number < 1) {
        //         number = 1;
        //     }
        //     if (number > max) {
        //         number = max;
        //     }
        //     $(this).val(number);
        // })

        $('.btn-apply').click(function (e) {
            let $form = $(e.currentTarget).parents("form");
            $.operate.submit({
                url: ctx + 'apply',
                data: new FormData($form[0]),
                fun: function (res) {
                    if (res.type === 'SUCCESS') {
                        $.box.toptip_s(res.msg);
                        location.href = ctx + "index";
                    } else {
                        $.box.toptip_w(res.msg);
                    }
                }
            });
        })

    })

    /**
     * 更改数量函数
     * 徐一贺
     */
    function changeDefVal() {
        let max = document.getElementById("weui-count__number").getAttribute("data")
        let number = document.getElementById("weui-count__number").value;
        if (parseInt(number) < 1) {
            number = 1;
        }
        if (parseInt(number) > parseInt(max)) {
            number = max;
        }
        document.getElementById("weui-count__number").value = number;
    }
</script>
</body>
</html>